cmake_minimum_required(VERSION 3.5)
project(gps_transform)

if(NOT WIN32)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
  message(STATUS "${PROJECT_NAME}: You did not request a specific build type: selecting 'RelWithDebInfo'.")
  set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif()

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(diagnostic_msgs REQUIRED)
find_package(diagnostic_updater REQUIRED)
# find_package(geographic_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
# find_package(rosidl_default_generators REQUIRED)
find_package(sensor_msgs REQUIRED)
# find_package(std_srvs REQUIRED)
find_package(tf2 REQUIRED)
# find_package(tf2_eigen REQUIRED)
# find_package(tf2_geometry_msgs REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(Eigen3 REQUIRED)
# find_package(Boost REQUIRED)
# find_package(yaml_cpp_vendor REQUIRED)

# find_package(OpenCV REQUIRED)

# Geographiclib installs FindGeographicLib.cmake to this non-standard location
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/usr/share/cmake/geographiclib/")
find_package(GeographicLib REQUIRED COMPONENTS STATIC)

set(library_name rl_lib)

# rosidl_generate_interfaces(${PROJECT_NAME}
#   "srv/FromLL.srv"
#   "srv/GetState.srv"
#   "srv/SetDatum.srv"
#   "srv/SetPose.srv"
#   "srv/ToggleFilterProcessing.srv"
#   "srv/ToLL.srv"
#   DEPENDENCIES
#     builtin_interfaces
#     geometry_msgs
#     geographic_msgs
#     diagnostic_msgs
#   ADD_LINTER_TESTS
# )

include_directories(SYSTEM ${Eigen_INCLUDE_DIRS})
include_directories(
  include
  ${EIGEN3_INCLUDE_DIRS}
  ${Boost_INCLUDE_DIRS}
)

add_library(
  ${library_name}
  src/navsat_transform.cpp
  )



add_executable(
  navsat_transform_node
  src/navsat_transform.cpp
)



target_link_libraries(
  ${library_name}
  ${GeographicLib_LIBRARIES}
  ${EIGEN3_LIBRARIES}
)

ament_target_dependencies(
  ${library_name}
  diagnostic_msgs
  diagnostic_updater
  # geographic_msgs
  geometry_msgs
  nav_msgs
  rclcpp
  sensor_msgs
  # std_msgs
  # std_srvs
  tf2
  # tf2_eigen
  # tf2_geometry_msgs
  tf2_ros
  # yaml_cpp_vendor
)


target_link_libraries(
  navsat_transform_node
  ${library_name}
)

ament_target_dependencies(
  navsat_transform_node
  rclcpp
)


install(
  TARGETS
  navsat_transform_node
  # navsat_alignment_node #wangshuo add
  # navsat_hand_eye_node #wangshuo add
  # navsat_hand_eye_offline_node #wangshuo add
  # ekf_node
  # ukf_node
  # robot_localization_listener_node
  RUNTIME DESTINATION lib/${PROJECT_NAME}
)

install(TARGETS ${library_name}
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION bin
)

install(DIRECTORY
  include/
  DESTINATION include
  USE_SOURCE_PERMISSIONS)

# Install params config files.
# install(DIRECTORY
#   params
#   launch
#   DESTINATION share/${PROJECT_NAME}
#   USE_SOURCE_PERMISSIONS
# )

ament_export_include_directories(include)
ament_export_libraries(${library_name})
ament_export_dependencies(rosidl_default_runtime)
ament_package()
